//Copyright 2010 Balazs Keri, Imre Keri
//
//This file is part of FireworksCreator.
//
//FireworksCreator is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//FireworksCreator is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with FireworksCreator.  If not, see <http://www.gnu.org/licenses/>.
//
#ifndef _PTTIMEMARKLISTVIEW_H
#define _PTTIMEMARKLISTVIEW_H
//
#include <QObject>
#include <model/particletemplate.h>
#include "view.h"
//
class QLayout;
class QPushButton;
class QGridLayout;
//class QHeaderView;
class QPushButton;
//class QSpacerItem;
class QTextEdit;
class QToolButton;
//class QVBoxLayout;
class PTTimeMarkView;
//
class PTTimeMarkListView:public QObject,public View
{
   Q_OBJECT
   Q_DISABLE_COPY(PTTimeMarkListView)
//construction
public:
   PTTimeMarkListView(QObject *p_parent=0);
   ~PTTimeMarkListView();
//signals
signals:
//slots
protected slots:
   void on_add_button_clicked();
   //void on_table_header_sectionResized(int logicalIndex,int oldSize,int newSize);
   void on_delete_button_clicked();
//View
protected:
   void handle_set_attr_group();
   void handle_attr_event(AttrEvent *p_ae);
   void handle_post_primitive(const Primitive &p_prim);
//access
public:
   QLayout *get_main_layout() const;
   QWidget *get_add_widget() const;
   QWidget *get_status_widget() const;
//implementation
private:
   model::ParticleTemplate *particle_template;
   QScopedPointer<QGridLayout> main_layout;
   //QVBoxLayout *head_layout;
   QScopedPointer<QPushButton> add_button;
   //QHeaderView *table_header;
   //QSpacerItem *col_spacer[3];
   QScopedPointer<QTextEdit> status_widget;
   QStringList ordered_tm_names;
   QList<PTTimeMarkView*> views;
   QList<QToolButton*> delete_buttons;
   void repopulate_layout();
   void recreate_views();
   void append_tm_view(QString tm_name);
   void insert_view(const QString &tm_name);
   void delete_view(const QString &tm_name);
   void move_view(const QString &tm_name_old,const QString &tm_name_new);
   void delete_views();
   QString find_tm_from_delete_button(const QToolButton *p_delete_button) const;
   void update_status() const;
};
//
#endif
